package com.mindspore.vision.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;

import com.mindspore.vision.R;
import com.mindspore.vision.ui.bean.ClassificationResultBean;

import java.util.List;

public class ClassificationChildAdapter extends RecyclerView.Adapter<ClassificationChildAdapter.ViewHolder> {

    private final List<ClassificationResultBean> mValues;
    private Context mContext;

    public ClassificationChildAdapter(Context mContext, List<ClassificationResultBean> items) {
        mValues = items;
        this.mContext = mContext;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new ViewHolder(LayoutInflater.from(mContext)
                .inflate(R.layout.fragment_classification_child, parent, false));
    }

    @Override
    public void onBindViewHolder(final ViewHolder holder, int position) {
        holder.mTitleView.setText(mValues.get(position).getTitle());
        holder.mContentView.setText(mValues.get(position).getContent());
    }

    @Override
    public int getItemCount() {
        return mValues.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        public TextView mTitleView;
        public TextView mContentView;
        public View mLine;

        public ViewHolder(View itemView) {
            super(itemView);
            mTitleView = itemView.findViewById(R.id.item_title);
            mContentView = itemView.findViewById(R.id.item_content);
//            mLine = itemView.findViewById(R.id.item_line);
        }
    }
}